//获取应用实例
const app = getApp()
const request = data => {
  return new Promise((resolve, reject) => {
    const header = {
      'cookie': wx.getStorageSync("setcookie")// 读取cookie
    }
    wx.request({
      url: app.globalData.host + data.url,
      method: data.method || 'GET',
      header: header, // 传在请求的header里
      data: {
        'data': data.param
      },
      success: function (res) {
        resolve(res)
      },
      fail: function (res) {
        reject(res)
      }
    })
  })
}

module.exports = request

